<?php
	/* Functions in this file */
	/**************************/

	// GetCapo()
	// GetChorus()
	// GetDescription()
	// GetInitialVolume()
	// GetMFCClassName()
	// GetMFCClassSchema()
	// GetNumber()
	// GetPan()
	// GetPhaser()
	// GetPreset()
	// GetReverb()
	// GetStringCount()
	// GetTremolo()
	// GetTuning()
	// GetTuningConstRef()
	// GetTuningPtr()
	// GetTuningRef()
	// GetTuningSpelling()
	// IsValidCapo($capo)
	// IsValidChorus($chorus)
	// IsValidInitialVolume($initialVolume)
	// IsValidPan($pan)
	// IsValidPhaser($phaser)
	// IsValidPreset($preset)
	// IsValidReverb($reverb)
	// IsValidTremolo($tremolo)
	// SetCapo($capo)
	// SetChorus($chorus)
	// SetDescription($description)
	// SetInitialVolume($initialVolume)
	// SetNumber($number)
	// SetPan($pan)
	// SetPhaser($phaser)
	// SetPreset($preset)
	// SetReverb($reverb)
	// SetTremolo($tremolo)
	// SetTuning(&$tuning)
	// UsesCapo()
?>
<?php
	 
	 
	class Guitar {
		 
		 
		// Constants
		const DEFAULT_NUMBER = 0;
		const DEFAULT_DESCRIPTION = "Untitled";
		const DEFAULT_PRESET = MIDI_PRESET_ACOUSTIC_GUITAR_STEEL;
		const DEFAULT_INITIAL_VOLUME = 104;
		const DEFAULT_PAN = self::PAN_CENTER;
		const DEFAULT_REVERB = MIN_MIDI_CHANNEL_EFFECT_LEVEL;
		const DEFAULT_CHORUS = MIN_MIDI_CHANNEL_EFFECT_LEVEL;
		const DEFAULT_TREMOLO = MIN_MIDI_CHANNEL_EFFECT_LEVEL;
		const DEFAULT_PHASER = MIN_MIDI_CHANNEL_EFFECT_LEVEL;
		const DEFAULT_CAPO = 0;
		 
		const MIN_PRESET = FIRST_MIDI_PRESET;
		const MAX_PRESET = LAST_MIDI_PRESET;
		 
		const MIN_INITIAL_VOLUME = MIN_MIDI_CHANNEL_VOLUME;
		const MAX_INITIAL_VOLUME = MAX_MIDI_CHANNEL_VOLUME;
		 
		const MIN_PAN = MIN_MIDI_CHANNEL_EFFECT_LEVEL;
		const MAX_PAN = MAX_MIDI_CHANNEL_EFFECT_LEVEL;
		const PAN_HARD_LEFT = self::MIN_PAN;
		const PAN_CENTER = 64;
		const PAN_HARD_RIGHT = self::MAX_PAN;
		 
		const MIN_REVERB = MIN_MIDI_CHANNEL_EFFECT_LEVEL;
		const MAX_REVERB = MAX_MIDI_CHANNEL_EFFECT_LEVEL;
		 
		const MIN_CHORUS = MIN_MIDI_CHANNEL_EFFECT_LEVEL;
		const MAX_CHORUS = MAX_MIDI_CHANNEL_EFFECT_LEVEL;
		 
		const MIN_TREMOLO = MIN_MIDI_CHANNEL_EFFECT_LEVEL;
		const MAX_TREMOLO = MAX_MIDI_CHANNEL_EFFECT_LEVEL;
		 
		const MIN_PHASER = MIN_MIDI_CHANNEL_EFFECT_LEVEL;
		const MAX_PHASER = MAX_MIDI_CHANNEL_EFFECT_LEVEL;
		 
		const MIN_CAPO = 0;
		const MAX_CAPO = 12;
		 
		 
		protected $m_number = self::DEFAULT_NUMBER;
		protected $m_description = self::DEFAULT_DESCRIPTION;
		protected $m_preset = self::DEFAULT_PRESET;
		protected $m_initialVolume = self::DEFAULT_INITIAL_VOLUME;
		protected $m_pan = self::DEFAULT_PAN;
		protected $m_reverb = self::DEFAULT_REVERB;
		protected $m_chorus = self::DEFAULT_CHORUS;
		protected $m_tremolo = self::DEFAULT_TREMOLO;
		protected $m_phaser = self::DEFAULT_PHASER;
		protected $m_capo = self::DEFAULT_CAPO;
		protected $m_tuning;
		 
		 
		// MFC Class Functions
		 
		 
		function GetMFCClassName() {
			return "CGuitar";
		}
		 
		 
		function GetMFCClassSchema() {
			return 1;
		}
		 
		// Number Functions
		 
		 
		function SetNumber($number) {
			$this->m_number = $number;
		}
		 
		 
		function GetNumber() {
			return ($this->m_number);
		}
		 
		// Description Functions
		 
		 
		 
		function SetDescription($description) {
			if (!$description) return 0;
			$this->m_description = $description;
			 return 1;
		}
		 
		 
		function GetDescription() {
			return ($this->m_description);
		}
		 
		// Preset Functions
		function IsValidPreset($preset) {
			return (($preset >= self::MIN_PRESET) && ($preset <= self::MAX_PRESET));
		}
		 
		 
		 
		function SetPreset($preset) {
			if (!$this->IsValidPreset($preset)) return 0;
			$this->m_preset = $preset;
			 return 1;
		}
		 
		 
		function GetPreset() {
			return ($this->m_preset);
		}
		 
		// Initial Volume Functions
		function IsValidInitialVolume($initialVolume) {
			return (($initialVolume >= self::MIN_INITIAL_VOLUME) && ($initialVolume <= self::MAX_INITIAL_VOLUME));
		}
		 
		 
		 
		function SetInitialVolume($initialVolume) {
			if (!$this->IsValidInitialVolume($initialVolume)) return 0;
			$this->m_initialVolume = $initialVolume;
			 return 1;
		}
		 
		 
		function GetInitialVolume() {
			return ($this->m_initialVolume);
		}
		 
		// Pan Functions
		 
		 
		 
		function IsValidPan($pan) {
			return (($pan >= self::MIN_PAN) && ($pan <= self::MAX_PAN));
		}
		 
		 
		 
		function SetPan($pan) {
			if (!$this->IsValidPan($pan)) return 0;
			$this->m_pan = $pan;
			 return 1;
		}
		 
		 
		function GetPan() {
			return ($this->m_pan);
		}
		 
		// Reverb Functions
		 
		 
		 
		function IsValidReverb($reverb) {
			return (($reverb >= self::MIN_REVERB) && ($reverb <= self::MAX_REVERB));
		}
		 
		 
		 
		function SetReverb($reverb) {
			if (!$this->IsValidReverb($reverb)) return 0;
			$this->m_reverb = $reverb;
			 return 1;
		}
		 
		 
		function GetReverb() {
			return ($this->m_reverb);
		}
		 
		// Chorus Functions
		 
		 
		 
		function IsValidChorus($chorus) {
			return (($chorus >= self::MIN_CHORUS) && ($chorus <= self::MAX_CHORUS));
		}
		 
		 
		 
		function SetChorus($chorus) {
			if (!$this->IsValidChorus($chorus)) return 0;
			$this->m_chorus = $chorus;
			 return 1;
		}
		 
		 
		function GetChorus() {
			return ($this->m_chorus);
		}
		 
		// Tremolo Functions
		 
		 
		 
		function IsValidTremolo($tremolo) {
			return (($tremolo >= self::MIN_TREMOLO) && ($tremolo <= self::MAX_TREMOLO));
		}
		 
		 
		 
		function SetTremolo($tremolo) {
			if (!$this->IsValidTremolo($tremolo)) return 0;
			$this->m_tremolo = $tremolo;
			 return 1;
		}
		 
		 
		function GetTremolo() {
			return ($this->m_tremolo);
		}
		 
		// Phaser Functions
		 
		 
		 
		function IsValidPhaser($phaser) {
			return (($phaser >= self::MIN_PHASER) && ($phaser <= self::MAX_PHASER));
		}
		 
		 
		 
		function SetPhaser($phaser) {
			if (!$this->IsValidPhaser($phaser)) return 0;
			$this->m_phaser = $phaser;
			 return 1;
		}
		 
		 
		function GetPhaser() {
			return ($this->m_phaser);
		}
		 
		// Capo Functions
		 
		 
		 
		function IsValidCapo($capo) {
			return (($capo >= self::MIN_CAPO) && ($capo <= self::MAX_CAPO));
		}
		 
		 
		 
		function SetCapo($capo) {
			if (!$this->IsValidCapo($capo)) return 0;
			$this->m_capo = $capo;
			 return 1;
		}
		 
		 
		function GetCapo() {
			return ($this->m_capo);
		}
		 
		 
		function UsesCapo() {
			return ($this->GetCapo() != self::MIN_CAPO);
		}
		 
		// Tuning Functions
		 
		 
		 
		function SetTuning(&$tuning) {
			if (!$tuning->IsValid()) return 0;
			$this->m_tuning = $tuning;
			 return 1;
		}
		 
		 
		function GetTuning() {
			return ($this->m_tuning);
		}
		 
		 
		function & GetTuningRef() {
			return ($this->m_tuning);
		}
		 
		 
		static function & GetTuningConstRef() {
			return ($this->m_tuning);
		}
		
		 
		function GetStringCount() {
			return ($this->m_tuning->GetStringCount());
		}
		 
		 
		function GetTuningSpelling() {
			return ($this->m_tuning->GetSpelling());
		}
		 
		 
		 
		function Guitar($number = NULL, $description = NULL, $preset = NULL, $initialVolume = NULL, $pan = NULL, $reverb = NULL, $chorus = NULL, $tremolo = NULL, $phaser = NULL, $capo = NULL) {
			 
			$this->m_tuning = new Tuning ();
			
			if (!$description) return 0;
			if (!wxIsValidMidiPreset($preset)) return 0;
			if (!wxIsValidMidiChannelVolume($initialVolume)) return 0;
			if (!$this->IsValidPan($pan)) return 0;
			if (!$this->IsValidReverb($reverb)) return 0;
			if (!$this->IsValidChorus($chorus)) return 0;
			if (!$this->IsValidTremolo($tremolo)) return 0;
			if (!$this->IsValidPhaser($phaser)) return 0;
			if (!$this->IsValidCapo($capo)) return 0;
			 
			 
			$this->m_number = $number;
			$this->m_description = $description;
			$this->m_preset = $preset;
			 $this->m_initialVolume = $initialVolume;
			$this->m_pan = $pan;
			$this->m_reverb = $reverb;
			$this->m_chorus = $chorus;
			$this->m_tremolo = $tremolo;
			$this->m_phaser = $phaser;
			 $this->m_capo = $capo;
			 
		}
		 
		 
		
		 
		function DoSerialize(&$stream){
		 
			WRITE_BYTE ($stream,$this->m_number);

			WRITE_CSTRING ($stream,$this->m_description);

			WRITE_BYTE ($stream,$this->m_preset);
			WRITE_BYTE ($stream,$this->m_initialVolume);
			WRITE_BYTE ($stream,$this->m_pan);
			WRITE_BYTE ($stream,$this->m_reverb);
			WRITE_BYTE ($stream,$this->m_chorus);
			WRITE_BYTE ($stream,$this->m_tremolo);
			WRITE_BYTE ($stream,$this->m_phaser);
			WRITE_BYTE ($stream,$this->m_capo);
			
			$this->m_tuning->DoSerialize($stream);
			

			return 1;
		}
		
		 
		function DoDeserialize(&$stream){
			
			$this->m_tuning = new Tuning ();
		 
			$this->m_number = READ_BYTE ($stream);
		 
			$this->m_description = READ_CSTRING ($stream);
		 
			$this->m_preset = READ_BYTE ($stream);
			$this->m_initialVolume = READ_BYTE ($stream);
			$this->m_pan = READ_BYTE ($stream);
			$this->m_reverb = READ_BYTE ($stream);
			$this->m_chorus = READ_BYTE ($stream);
			$this->m_tremolo = READ_BYTE ($stream);
			$this->m_phaser = READ_BYTE ($stream);
			$this->m_capo = READ_BYTE ($stream);
		 
			$this->m_tuning->DoDeserialize($stream);
			
		
		}
		 
		
		// Operations
		 
		 
		 
	}
?>

